/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package isd.facturacion.modelo;

import isd.general.auditoria.AuditoriaListener;
import isd.general.modelo.GR_Auditoria;
import isd.general.modelo.GR_Moneda;
import isd.general.modelo.GR_Sucursal;
import isd.inventario.modelo.ST_Deposito;
import isd.inventario.modelo.ST_Producto;
import isd.inventario.modelo.ST_Sector;
import isd.inventario.modelo.ST_UnidadMedida;
import isd.ventas.modelo.VT_Cliente;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;



/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "fcrmvi")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "OALIAS", discriminatorType = DiscriminatorType.STRING, length = 1)
@EntityListeners(AuditoriaListener.class)
@IdClass(FC_ItemMovimientoPK.class)
public abstract class FC_ItemMovimiento implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "FCRMVI_MODFOR", nullable = false, length = 2)
    private String modfor;
    @Id
    @Column(name = "FCRMVI_CODFOR", nullable = false, length = 6)
    private String codfor;
    @Id
    @Column(name = "FCRMVI_NROFOR", nullable = false)
    private int nrofor;
    @Id
    @Column(name = "FCRMVI_NROITM", nullable = false)
    private int nroitm;
    @Id
    @Column(name = "FCRMVI_NIVEXP", nullable = false, length = 2)
    private String nivexp;
    @Id
    @Column(name = "FCRMVI_MODAPL", nullable = false, length = 2)
    private String modapl;
    @Id
    @Column(name = "FCRMVI_CODAPL", nullable = false, length = 6)
    private String codapl;
    @Id
    @Column(name = "FCRMVI_NROAPL", nullable = false)
    private int nroapl;
    @Id
    @Column(name = "FCRMVI_ITMAPL", nullable = false)
    private int itmapl;
    @Id
    @Column(name = "FCRMVI_EXPAPL", nullable = false, length = 2)
    private String expapl;

    @JoinColumns({
        @JoinColumn(name = "FCRMVI_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false, insertable=true, updatable=true),
        @JoinColumn(name = "FCRMVI_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false, insertable=true, updatable=true)
    })
    @ManyToOne(optional=false)
    private ST_Producto producto;
    
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_MODFOR", referencedColumnName = "FCRMVH_MODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_CODFOR", referencedColumnName = "FCRMVH_CODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_NROFOR", referencedColumnName = "FCRMVH_NROFOR", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne
    FC_Movimiento movimiento;
   
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_MODAPL", referencedColumnName = "FCRMVH_MODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_CODAPL", referencedColumnName = "FCRMVH_CODFOR", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_NROAPL", referencedColumnName = "FCRMVH_NROFOR", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne
    FC_Movimiento movimientoAplicacion;

        /**
     * Movimiento original
     */
    @JoinColumns({
    @JoinColumn(name = "FCRMVI_MODORI", referencedColumnName = "FCRMVH_MODFOR", nullable = false,insertable=false, updatable=false),
    @JoinColumn(name = "FCRMVI_CODORI", referencedColumnName = "FCRMVH_CODFOR", nullable = false,insertable=false, updatable=false),
    @JoinColumn(name = "FCRMVI_NROORI", referencedColumnName = "FCRMVH_NROFOR", nullable = false,insertable=false, updatable=false)
    })
    @ManyToOne
    private FC_Movimiento movimientoOriginal;

    @Column(name = "FCRMVI_MODORI", nullable = false, length = 2)
    private String modori;
    @Column(name = "FCRMVI_CODORI", nullable = false, length = 6)
    private String codori;
    @Column(name = "FCRMVI_NROORI", nullable = false)
    private int nroori;

     /**
     * Movimiento inicial
     */
    @JoinColumns({
    @JoinColumn(name = "FCRMVI_MODINI", referencedColumnName = "FCRMVH_MODFOR", nullable = false),
    @JoinColumn(name = "FCRMVI_CODINI", referencedColumnName = "FCRMVH_CODFOR", nullable = false),
    @JoinColumn(name = "FCRMVI_NROINI", referencedColumnName = "FCRMVH_NROFOR", nullable = false)
    })
    @ManyToOne
    private FC_Movimiento movimientoInicial;

    @Column(name = "FCRMVI_MODCPT", length = 2)
    private String modcpt;
    @Column(name = "FCRMVI_TIPCPT")
    private Character tipcpt;
    @Column(name = "FCRMVI_CODCPT", length = 6)
    private String codcpt;

    @JoinColumns({
    @JoinColumn(name = "FCRMVI_TIPORI", referencedColumnName = "STMPDH_TIPPRO", nullable = false),
    @JoinColumn(name = "FCRMVI_ARTORI", referencedColumnName = "STMPDH_ARTCOD", nullable = false)
    })
    @ManyToOne(optional=false)
    private ST_Producto productoOriginal;
    
 

    //Numero de Serie
    @Column(name = "FCRMVI_NSERIE", length = 30)
    private String nserie;
    //Numero de despacho
    @Column(name = "FCRMVI_NDESPA", length = 30)
    private String ndespa;
    //Numero de envase
    @Column(name = "FCRMVI_ENVASE", length = 30)
    private String envase;
    //Numero otros
    @Column(name = "FCRMVI_NOTROS", length = 30)
    private String notros;
    //Numero de atributo
    @Column(name = "FCRMVI_NATRIB", length = 30)
    private String natrib;
    //Numero de estante
    @Column(name = "FCRMVI_NESTAN", length = 30)
    private String nestan;
    //Numero de ubicacion
    @Column(name = "FCRMVI_NUBICA", length = 30)
    private String nubica;
    //Fecha
    @Column(name = "FCRMVI_NFECHA", length = 30)
    private String nfecha;    
    @Column(name = "FCRMVI_TSERIE", length = 30)
    private String tserie;
    @Column(name = "FCRMVI_TDESPA", length = 30)
    private String tdespa;
    @Column(name = "FCRMVI_TENVAS", length = 30)
    private String tenvas;
    @Column(name = "FCRMVI_TOTROS", length = 30)
    private String totros;
    @Column(name = "FCRMVI_TATRIB", length = 30)
    private String tatrib;
    @Column(name = "FCRMVI_TESTAN", length = 30)
    private String testan;
    @Column(name = "FCRMVI_TUBICA", length = 30)
    private String tubica;
    @Column(name = "FCRMVI_TFECHA", length = 30)
    private String tfecha;

    //Deposito
    @JoinColumn(name = "FCRMVI_DEPOSI", referencedColumnName = "STTDEH_DEPOSI", nullable = true)
    @ManyToOne(optional=false)
    private ST_Deposito deposito;

    //Sector
    @JoinColumns({
        @JoinColumn(name = "FCRMVI_DEPOSI", referencedColumnName = "STTDEI_DEPOSI", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "FCRMVI_SECTOR", referencedColumnName = "STTDEI_SECTOR", nullable = false)
    })
    @ManyToOne
    private ST_Sector sector;


    //Sucursal o punto de venta
    @JoinColumn(name = "FCRMVI_SUCURS", referencedColumnName = "GRTSUC_SUCURS", nullable = false)
    @ManyToOne
    private GR_Sucursal sucursal;

    //Cliente
    @JoinColumn(name = "FCRMVI_NROCTA", referencedColumnName = "VTMCLH_NROCTA", nullable = false)
    @ManyToOne(optional = false)
    private VT_Cliente cliente;

    @Column(name = "FCRMVI_NROSUB", length = 13)
    private String nrosub;

    @Column(name = "FCRMVI_OLDPRE", precision = 20, scale = 4)
    private BigDecimal oldpre;
    @Column(name = "FCRMVI_NEWPRE", precision = 20, scale = 4)
    private BigDecimal newpre;
    @Column(name = "FCRMVI_PRECIO", precision = 20, scale = 4)
    private BigDecimal precio;
    @Column(name = "FCRMVI_CANTID", precision = 18, scale = 4)    
    private BigDecimal cantid;
    @Column(name = "FCRMVI_FACSEC", precision = 12, scale = 4)
    private BigDecimal facsec;
    @Column(name = "FCRMVI_CNTSEC", precision = 18, scale = 4)
    private BigDecimal cntsec;

    /**
     * Unidad de medida
     */
    @ManyToOne
    @JoinColumn(name = "FCRMVI_UNIMED", referencedColumnName = "STTUNI_UNIDAD", nullable = false, insertable=false, updatable=false)
    private ST_UnidadMedida unidadMedida;

    @Column(name = "FCRMVI_UNISEC", length = 6)
    private String unisec;
    @Column(name = "FCRMVI_TIPUNI", length = 1)
    private String tipuni;
    @Column(name = "FCRMVI_UNIFAC", length = 6)
    private String unifac;
    @Column(name = "FCRMVI_FACFAC", precision = 12, scale = 4)
    private BigDecimal facfac;
    @Column(name = "FCRMVI_CNTFAC", precision = 18, scale = 4)
    private BigDecimal cntfac;
    @Column(name = "FCRMVI_UNIALT", length = 6)
    private String unialt;
    @Column(name = "FCRMVI_FACALT", precision = 12, scale = 4)
    private BigDecimal facalt;
    @Column(name = "FCRMVI_CNTALT", precision = 18, scale = 4)
    private BigDecimal cntalt;
    @Column(name = "FCRMVI_UNICON", length = 6)
    private String unicon;
    @Column(name = "FCRMVI_FACCON", precision = 12, scale = 4)
    private BigDecimal faccon;
    @Column(name = "FCRMVI_CNTCON", precision = 18, scale = 4)
    private BigDecimal cntcon;
    @Column(name = "FCRMVI_FCHENT")
    @Temporal(TemporalType.DATE)
    private Date fechaEntregaDesde;
    @Column(name = "FCRMVI_FCHHAS")
    @Temporal(TemporalType.DATE)
    private Date fechaEntregaHasta;
    @Column(name = "FCRMVI_PCTBF1", precision = 15, scale = 4)
    private BigDecimal pctbf1;
    @Column(name = "FCRMVI_PCTBF2", precision = 15, scale = 4)
    private BigDecimal pctbf2;
    @Column(name = "FCRMVI_PCTBF3", precision = 15, scale = 4)
    private BigDecimal pctbf3;
    @Column(name = "FCRMVI_PCTBF4", precision = 15, scale = 4)
    private BigDecimal pctbf4;
    @Column(name = "FCRMVI_PCTBF5", precision = 15, scale = 4)
    private BigDecimal pctbf5;
    @Column(name = "FCRMVI_PCTBF6", precision = 15, scale = 4)
    private BigDecimal pctbf6;
    @Column(name = "FCRMVI_PCTBF7", precision = 15, scale = 4)
    private BigDecimal pctbf7;
    @Column(name = "FCRMVI_PCTBF8", precision = 15, scale = 4)
    private BigDecimal pctbf8;
    @Column(name = "FCRMVI_PCTBF9", precision = 15, scale = 4)
    private BigDecimal pctbf9;
    @Column(name = "FCRMVI_PCTBFN", precision = 15, scale = 4)
    private BigDecimal pctbfn;
    @Lob
    @Column(name = "FCRMVI_TEXTOS", length = 2147483647)
    private String textos;
    @Column(name = "FCRMVI_CNTPEN", precision = 18, scale = 4)
    private BigDecimal cantidadPendiente;

    @Column(name = "FCRMVI_ITMORI")
    private Integer itmori;
    @Column(name = "FCRMVI_EXPORI", length = 2)
    private String expori;
    @Column(name = "FCRMVI_CNTBON", precision = 18, scale = 4)
    private BigDecimal cntbon;
    @Column(name = "FCRMVI_CUENTA", length = 40)
    private String cuenta;
    @Column(name = "FCRMVI_CNTANT", precision = 18, scale = 4)
    private BigDecimal cntant;
    @Column(name = "FCRMVI_PORANT", precision = 15, scale = 4)
    private BigDecimal porant;
    @Column(name = "FCRMVI_ARTEQU", length = 60)
    private String artequ;
    @Column(name = "FCRMVI_CANTST", precision = 18, scale = 4)
    private BigDecimal cantst;
    @Column(name = "FCRMVI_CNTORI", precision = 18, scale = 4)
    private BigDecimal cntori;
    @Column(name = "FCRMVI_MCDAPL", length = 2)
    private String mcdapl;
    @Column(name = "FCRMVI_CCDAPL", length = 6)
    private String ccdapl;
    @Column(name = "FCRMVI_DEPTRA", length = 15)
    private String deptra;
    @Column(name = "FCRMVI_SECTRA", length = 15)
    private String sectra;

    @Column(name = "FCRMVI_ITMINI")
    private Integer itmini;
    @Column(name = "FCRMVI_NIVINI", length = 2)
    private String nivini;
    //Moneda ultima compra
    @JoinColumn(name = "FCRMVI_COFLIS", referencedColumnName = "GRTCOF_CODCOF", nullable = false)
    @ManyToOne
    private GR_Moneda monedaListaPrecio;
    

    @Column(name = "FCRMVI_CAMBIO", precision = 20, scale = 4)
    private BigDecimal cambio;
    @Column(name = "FCRMVI_MODGAN", length = 2)
    private String modgan;
    @Column(name = "FCRMVI_CODGAN", length = 6)
    private String codgan;
    @Column(name = "FCRMVI_NROGAN")
    private Integer nrogan;
    @Column(name = "FCRMVI_CNTVAR", precision = 18, scale = 4)
    private BigDecimal cntvar;
    @Column(name = "FCRMVI_CNTUNI", precision = 18, scale = 4)
    private BigDecimal cntuni;
    @Column(name = "FCRMVI_FACTOR", precision = 12, scale = 4)
    private BigDecimal factor;
    @Column(name = "FCRMVI_NCNPNA")
    private Character ncnpna;
    @Column(name = "FCRMVI_NGENPN")
    private Character ngenpn;
    @Column(name = "FCRMVI_NCANPN")
    private Character ncanpn;
    @Column(name = "FCRMVI_NGENST")
    private Character ngenst;
    @Column(name = "FCRMVI_PRESEC", precision = 20, scale = 4)
    private BigDecimal presec;
    @Column(name = "FCRMVI_TIPOPR", length = 6)
    private String tipopr;
    @Column(name = "FCRMVI_CODOPR", length = 30)
    private String codopr;
    @Column(name = "FCRMVI_CODEMP", length = 10)
    private String codemp;
    @Column(name = "FCRMVI_EMPAPL", length = 10)
    private String empapl;
    @Column(name = "FCRMVI_EMPGAN", length = 10)
    private String empgan;
    @Column(name = "FCRMVI_EMPINI", length = 10)
    private String empini;
    @Column(name = "FCRMVI_EMPORI", length = 10)
    private String empori;
    @Column(name = "FCRMVI_PCTCOM", precision = 15, scale = 4)
    private BigDecimal pctcom;
    @Column(name = "FCRMVI_MODOST", length = 2)
    private String modost;
    @Column(name = "FCRMVI_CODOST", length = 6)
    private String codost;
    @Column(name = "FCRMVI_NROOST")
    private Integer nroost;
    @Column(name = "FCRMVI_ITMOST")
    private Integer itmost;
    @Column(name = "FCRMVI_EXPOST", length = 2)
    private String expost;
    @Column(name = "FCRMVI_EMPOST", length = 10)
    private String empost;
    @Column(name = "FCRMVI_PRENAC", precision = 20, scale = 4)
    private BigDecimal prenac;
    @Column(name = "FCRMVI_PREEXT", precision = 20, scale = 4)
    private BigDecimal preext;
    @Column(name = "FCRMVI_PREUSS", precision = 20, scale = 4)
    private BigDecimal preuss;

    //Total de linea
    @Column(name = "FCRMVI_TOTLIN", precision = 15, scale = 4)
    private BigDecimal totlin;

    @Embedded
    private GR_Auditoria auditoria;

    @Transient
    private BigDecimal pendiente;

    @Transient
    private BigDecimal precioListaConIVA;

    @Transient
    private BigDecimal precioFinalConIVA;

    @Transient
    private BigDecimal precioFinalSinIVA;

    @Transient
    private BigDecimal totalPendienteSinIVA;

    @Transient
    private BigDecimal totalPendienteConIVA;

    @Transient
    private BigDecimal totalLineaSinIVA;

    @Transient
    private BigDecimal totalLineaConIVA;



    public FC_ItemMovimiento() {
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        auditoria = new GR_Auditoria();

        
    }

    public FC_ItemMovimiento(FC_ItemMovimientoPK idPK) {
        modfor = idPK.getModfor();
        codfor = idPK.getCodfor();
        nrofor = idPK.getNrofor();
        nroitm = idPK.getNroitm();
        nivexp = idPK.getNivexp();
        modapl = idPK.getModapl();
        codapl = idPK.getCodapl();
        nroapl = idPK.getNroapl();
        itmapl = idPK.getItmapl();
        expapl = idPK.getExpapl();
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        auditoria = new GR_Auditoria();

    }

    public FC_ItemMovimiento(FC_ItemMovimientoPK idPK, ST_Producto producto) {

        modfor = idPK.getModfor();
        codfor = idPK.getCodfor();
        nrofor = idPK.getNrofor();
        nroitm = idPK.getNroitm();
        nivexp = idPK.getNivexp();
        modapl = idPK.getModapl();
        codapl = idPK.getCodapl();
        nroapl = idPK.getNroapl();
        itmapl = idPK.getItmapl();
        expapl = idPK.getExpapl();
        this.producto = producto;
        oldpre = BigDecimal.ZERO;
        newpre = BigDecimal.ZERO;
        facsec = BigDecimal.ZERO;
        cntsec = BigDecimal.ZERO;
        facfac = BigDecimal.ZERO;
        pctbf2 = BigDecimal.ZERO;
        pctbf3 = BigDecimal.ZERO;
        pctbf4 = BigDecimal.ZERO;
        pctbf5 = BigDecimal.ZERO;
        pctbf6 = BigDecimal.ZERO;
        pctbf7 = BigDecimal.ZERO;
        pctbf8 = BigDecimal.ZERO;
        pctbf9 = BigDecimal.ZERO;
        cntbon = BigDecimal.ZERO;
        cntalt = BigDecimal.ZERO;
        cntant = BigDecimal.ZERO;
        porant = BigDecimal.ZERO;
        cambio = BigDecimal.ZERO;
        cntvar = BigDecimal.ZERO;
        cntuni = BigDecimal.ZERO;
        factor = BigDecimal.ZERO;
        preext = BigDecimal.ZERO;
        preuss = BigDecimal.ZERO;
        ncnpna = 'N';
        codopr = "";
        codemp = "TEM";
        empapl = "TEM";
        empini = "TEM";
        empori = "TEM";
        auditoria = new GR_Auditoria();
        
        if(producto!=null){
            productoOriginal = producto;
            tipcpt = producto.getTipcpt();
            modcpt = producto.getModcpt();
            codcpt = producto.getCodcpt();
            cuenta = producto.getCuenvt();
            
        }
    }
    
    public String getCodapl() {
        return codapl;
    }

    public void setCodapl(String codapl) {
        this.codapl = codapl;
    }

    public String getCodfor() {
        return codfor;
    }

    public void setCodfor(String codfor) {
        this.codfor = codfor;
    }

    public String getExpapl() {
        return expapl;
    }

    public void setExpapl(String expapl) {
        this.expapl = expapl;
    }

    public int getItmapl() {
        return itmapl;
    }

    public void setItmapl(int itmapl) {
        this.itmapl = itmapl;
    }

    public String getModapl() {
        return modapl;
    }

    public void setModapl(String modapl) {
        this.modapl = modapl;
    }

    public String getModfor() {
        return modfor;
    }

    public void setModfor(String modfor) {
        this.modfor = modfor;
    }

    public String getNivexp() {
        return nivexp;
    }

    public void setNivexp(String nivexp) {
        this.nivexp = nivexp;
    }

    public int getNroapl() {
        return nroapl;
    }

    public void setNroapl(int nroapl) {
        this.nroapl = nroapl;
    }

    public int getNrofor() {
        return nrofor;
    }

    public void setNrofor(int nrofor) {
        this.nrofor = nrofor;
    }

    public int getNroitm() {
        return nroitm;
    }

    public void setNroitm(int nroitm) {
        this.nroitm = nroitm;
    }

    public String getArtequ() {
        return artequ;
    }

    public void setArtequ(String artequ) {
        this.artequ = artequ;
    }

    public BigDecimal getCambio() {
        return cambio;
    }

    public void setCambio(BigDecimal cambio) {
        this.cambio = cambio;
    }

    public BigDecimal getCantid() {
        return cantid;
    }

    public void setCantid(BigDecimal cantid) {
        this.cantid = cantid;
        if(cantid!=null){
            cntfac = cantid;
            cntalt = cantid;
            cntcon = cantid;
        }
    }

    public BigDecimal getCantst() {
        return cantst;
    }

    public void setCantst(BigDecimal cantst) {
        this.cantst = cantst;
    }

    public String getCcdapl() {
        return ccdapl;
    }

    public void setCcdapl(String ccdapl) {
        this.ccdapl = ccdapl;
    }

    public BigDecimal getCntalt() {
        return cntalt;
    }

    public void setCntalt(BigDecimal cntalt) {
        this.cntalt = cntalt;
    }

    public BigDecimal getCntant() {
        return cntant;
    }

    public void setCntant(BigDecimal cntant) {
        this.cntant = cntant;
    }

    public BigDecimal getCntbon() {
        return cntbon;
    }

    public void setCntbon(BigDecimal cntbon) {
        this.cntbon = cntbon;
    }

    public BigDecimal getCntcon() {
        return cntcon;
    }

    public void setCntcon(BigDecimal cntcon) {
        this.cntcon = cntcon;
    }

    public BigDecimal getCntfac() {
        return cntfac;
    }

    public void setCntfac(BigDecimal cntfac) {
        this.cntfac = cntfac;
    }

    public BigDecimal getCntori() {
        return cntori;
    }

    public void setCntori(BigDecimal cntori) {
        this.cntori = cntori;
    }

    public BigDecimal getCntsec() {
        return cntsec;
    }

    public void setCntsec(BigDecimal cntsec) {
        this.cntsec = cntsec;
    }

    public BigDecimal getCntuni() {
        return cntuni;
    }

    public void setCntuni(BigDecimal cntuni) {
        this.cntuni = cntuni;
    }

    public BigDecimal getCntvar() {
        return cntvar;
    }

    public void setCntvar(BigDecimal cntvar) {
        this.cntvar = cntvar;
    }

    public String getCodcpt() {
        return codcpt;
    }

    public void setCodcpt(String codcpt) {
        this.codcpt = codcpt;
    }

    public String getCodemp() {
        return codemp;
    }

    public void setCodemp(String codemp) {
        this.codemp = codemp;
    }

    public String getCodgan() {
        return codgan;
    }

    public void setCodgan(String codgan) {
        this.codgan = codgan;
    }

    public String getCodopr() {
        return codopr;
    }

    public void setCodopr(String codopr) {
        this.codopr = codopr;
    }

    public String getCodost() {
        return codost;
    }

    public void setCodost(String codost) {
        this.codost = codost;
    }

    public String getCuenta() {
        return cuenta;
    }

    public void setCuenta(String cuenta) {
        this.cuenta = cuenta;
    }

    public String getDeptra() {
        return deptra;
    }

    public void setDeptra(String deptra) {
        this.deptra = deptra;
    }

    public String getEmpapl() {
        return empapl;
    }

    public void setEmpapl(String empapl) {
        this.empapl = empapl;
    }

    public String getEmpgan() {
        return empgan;
    }

    public void setEmpgan(String empgan) {
        this.empgan = empgan;
    }

    public String getEmpini() {
        return empini;
    }

    public void setEmpini(String empini) {
        this.empini = empini;
    }

    public String getEmpori() {
        return empori;
    }

    public void setEmpori(String empori) {
        this.empori = empori;
    }

    public String getEmpost() {
        return empost;
    }

    public void setEmpost(String empost) {
        this.empost = empost;
    }

    public String getEnvase() {
        return envase;
    }

    public void setEnvase(String envase) {
        this.envase = envase;
    }

    public String getExpori() {
        return expori;
    }

    public void setExpori(String expori) {
        this.expori = expori;
    }

    public String getExpost() {
        return expost;
    }

    public void setExpost(String expost) {
        this.expost = expost;
    }

    public BigDecimal getFacalt() {
        return facalt;
    }

    public void setFacalt(BigDecimal facalt) {
        this.facalt = facalt;
    }

    public BigDecimal getFaccon() {
        return faccon;
    }

    public void setFaccon(BigDecimal faccon) {
        this.faccon = faccon;
    }

    public BigDecimal getFacfac() {
        return facfac;
    }

    public void setFacfac(BigDecimal facfac) {
        this.facfac = facfac;
    }

    public BigDecimal getFacsec() {
        return facsec;
    }

    public void setFacsec(BigDecimal facsec) {
        this.facsec = facsec;
    }

    public BigDecimal getFactor() {
        return factor;
    }

    public void setFactor(BigDecimal factor) {
        this.factor = factor;
    }

    public BigDecimal getCantidadPendiente() {
        return cantidadPendiente;
    }

    public void setCantidadPendiente(BigDecimal cantidadPendiente) {
        this.cantidadPendiente = cantidadPendiente;
    }

    public Date getFechaEntregaDesde() {
        return fechaEntregaDesde;
    }

    public void setFechaEntregaDesde(Date fechaEntregaDesde) {
        this.fechaEntregaDesde = fechaEntregaDesde;
    }

    public Date getFechaEntregaHasta() {
        return fechaEntregaHasta;
    }

    public void setFechaEntregaHasta(Date fechaEntregaHasta) {
        this.fechaEntregaHasta = fechaEntregaHasta;
    }

    public Integer getItmini() {
        return itmini;
    }

    public void setItmini(Integer itmini) {
        this.itmini = itmini;
    }

    public Integer getItmori() {
        return itmori;
    }

    public void setItmori(Integer itmori) {
        this.itmori = itmori;
    }

    public Integer getItmost() {
        return itmost;
    }

    public void setItmost(Integer itmost) {
        this.itmost = itmost;
    }

    public String getMcdapl() {
        return mcdapl;
    }

    public void setMcdapl(String mcdapl) {
        this.mcdapl = mcdapl;
    }

    public String getModcpt() {
        return modcpt;
    }

    public void setModcpt(String modcpt) {
        this.modcpt = modcpt;
    }

    public String getModgan() {
        return modgan;
    }

    public void setModgan(String modgan) {
        this.modgan = modgan;
    }

    public String getModost() {
        return modost;
    }

    public void setModost(String modost) {
        this.modost = modost;
    }

    public FC_Movimiento getMovimiento() {
        return movimiento;
    }

    public void setMovimiento(FC_Movimiento movimiento) {
        this.movimiento = movimiento;
    }

    public String getNatrib() {
        return natrib;
    }

    public void setNatrib(String natrib) {
        this.natrib = natrib;
    }

    public Character getNcanpn() {
        return ncanpn;
    }

    public void setNcanpn(Character ncanpn) {
        this.ncanpn = ncanpn;
    }

    public Character getNcnpna() {
        return ncnpna;
    }

    public void setNcnpna(Character ncnpna) {
        this.ncnpna = ncnpna;
    }

    public String getNdespa() {
        return ndespa;
    }

    public void setNdespa(String ndespa) {
        this.ndespa = ndespa;
    }

    public String getNestan() {
        return nestan;
    }

    public void setNestan(String nestan) {
        this.nestan = nestan;
    }

    public BigDecimal getNewpre() {
        return newpre;
    }

    public void setNewpre(BigDecimal newpre) {
        this.newpre = newpre;
    }

    public String getNfecha() {
        return nfecha;
    }

    public void setNfecha(String nfecha) {
        this.nfecha = nfecha;
    }

    public Character getNgenpn() {
        return ngenpn;
    }

    public void setNgenpn(Character ngenpn) {
        this.ngenpn = ngenpn;
    }

    public Character getNgenst() {
        return ngenst;
    }

    public void setNgenst(Character ngenst) {
        this.ngenst = ngenst;
    }

    public String getNivini() {
        return nivini;
    }

    public void setNivini(String nivini) {
        this.nivini = nivini;
    }

    public String getNotros() {
        return notros;
    }

    public void setNotros(String notros) {
        this.notros = notros;
    }

    public VT_Cliente getCliente() {
        return cliente;
    }

    public void setCliente(VT_Cliente cliente) {
        this.cliente = cliente;
        if(cliente!=null){
            nrosub = cliente.getNrocta();
        }
    }
    
    public Integer getNrogan() {
        return nrogan;
    }

    public void setNrogan(Integer nrogan) {
        this.nrogan = nrogan;
    }

    public Integer getNroost() {
        return nroost;
    }

    public void setNroost(Integer nroost) {
        this.nroost = nroost;
    }

    public String getNrosub() {
        return nrosub;
    }

    public void setNrosub(String nrosub) {
        this.nrosub = nrosub;
    }

    public String getNserie() {
        return nserie;
    }

    public void setNserie(String nserie) {
        this.nserie = nserie;
    }

    public String getNubica() {
        return nubica;
    }

    public void setNubica(String nubica) {
        this.nubica = nubica;
    }

    public BigDecimal getOldpre() {
        return oldpre;
    }

    public void setOldpre(BigDecimal oldpre) {
        this.oldpre = oldpre;
    }

    public BigDecimal getPctbf1() {
        return pctbf1;
    }

    public void setPctbf1(BigDecimal pctbf1) {
        this.pctbf1 = pctbf1;
    }

    public BigDecimal getPctbf2() {
        return pctbf2;
    }

    public void setPctbf2(BigDecimal pctbf2) {
        this.pctbf2 = pctbf2;
    }

    public BigDecimal getPctbf3() {
        return pctbf3;
    }

    public void setPctbf3(BigDecimal pctbf3) {
        this.pctbf3 = pctbf3;
    }

    public BigDecimal getPctbf4() {
        return pctbf4;
    }

    public void setPctbf4(BigDecimal pctbf4) {
        this.pctbf4 = pctbf4;
    }

    public BigDecimal getPctbf5() {
        return pctbf5;
    }

    public void setPctbf5(BigDecimal pctbf5) {
        this.pctbf5 = pctbf5;
    }

    public BigDecimal getPctbf6() {
        return pctbf6;
    }

    public void setPctbf6(BigDecimal pctbf6) {
        this.pctbf6 = pctbf6;
    }

    public BigDecimal getPctbf7() {
        return pctbf7;
    }

    public void setPctbf7(BigDecimal pctbf7) {
        this.pctbf7 = pctbf7;
    }

    public BigDecimal getPctbf8() {
        return pctbf8;
    }

    public void setPctbf8(BigDecimal pctbf8) {
        this.pctbf8 = pctbf8;
    }

    public BigDecimal getPctbf9() {
        return pctbf9;
    }

    public void setPctbf9(BigDecimal pctbf9) {
        this.pctbf9 = pctbf9;
    }

    public BigDecimal getPctbfn() {
        return pctbfn;
    }

    public void setPctbfn(BigDecimal pctbfn) {
        this.pctbfn = pctbfn;
    }

    public BigDecimal getPctcom() {
        return pctcom;
    }

    public void setPctcom(BigDecimal pctcom) {
        this.pctcom = pctcom;
    }

    public BigDecimal getPorant() {
        return porant;
    }

    public void setPorant(BigDecimal porant) {
        this.porant = porant;
    }

    public BigDecimal getPrecio() {
        return precio;
    }

    public void setPrecio(BigDecimal precio) {
        this.precio = precio;
    }

    public BigDecimal getPreext() {
        return preext;
    }

    public void setPreext(BigDecimal preext) {
        this.preext = preext;
    }

    public BigDecimal getPrenac() {
        return prenac;
    }

    public void setPrenac(BigDecimal prenac) {
        this.prenac = prenac;
    }

    public BigDecimal getPresec() {
        return presec;
    }

    public void setPresec(BigDecimal presec) {
        this.presec = presec;
    }

    public BigDecimal getPreuss() {
        return preuss;
    }

    public void setPreuss(BigDecimal preuss) {
        this.preuss = preuss;
    }

    public ST_Producto getProducto() {
        return producto;
    }

    public void setProducto(ST_Producto producto) {
        this.producto = producto;
    }
    
    public ST_Deposito getDeposito() {
        return deposito;
    }

    public void setDeposito(ST_Deposito deposito) {
        this.deposito = deposito;
    }

    public GR_Moneda getMonedaListaPrecio() {
        return monedaListaPrecio;
    }

    public void setMonedaListaPrecio(GR_Moneda monedaListaPrecio) {
        this.monedaListaPrecio = monedaListaPrecio;
    }

    public ST_Sector getSector() {
        return sector;
    }

    public void setSector(ST_Sector sector) {
        this.sector = sector;
    }

    public GR_Sucursal getSucursal() {
        return sucursal;
    }

    public void setSucursal(GR_Sucursal sucursal) {
        this.sucursal = sucursal;
    }
    
    public String getSectra() {
        return sectra;
    }

    public void setSectra(String sectra) {
        this.sectra = sectra;
    }

    public String getTatrib() {
        return tatrib;
    }

    public void setTatrib(String tatrib) {
        this.tatrib = tatrib;
    }

    public String getTdespa() {
        return tdespa;
    }

    public void setTdespa(String tdespa) {
        this.tdespa = tdespa;
    }

    public String getTenvas() {
        return tenvas;
    }

    public void setTenvas(String tenvas) {
        this.tenvas = tenvas;
    }

    public String getTestan() {
        return testan;
    }

    public void setTestan(String testan) {
        this.testan = testan;
    }

    public String getTextos() {
        return textos;
    }

    public void setTextos(String textos) {
        this.textos = textos;
    }

    public String getTfecha() {
        return tfecha;
    }

    public void setTfecha(String tfecha) {
        this.tfecha = tfecha;
    }

    public Character getTipcpt() {
        return tipcpt;
    }

    public void setTipcpt(Character tipcpt) {
        this.tipcpt = tipcpt;
    }

    public String getTipopr() {
        return tipopr;
    }

    public void setTipopr(String tipopr) {
        this.tipopr = tipopr;
    }

    public String getTipuni() {
        return tipuni;
    }

    public void setTipuni(String tipuni) {
        this.tipuni = tipuni;
    }

    public BigDecimal getTotlin() {
        return totlin;
    }

    public void setTotlin(BigDecimal totlin) {
        this.totlin = totlin;
    }

    public String getTotros() {
        return totros;
    }

    public void setTotros(String totros) {
        this.totros = totros;
    }

    public String getTserie() {
        return tserie;
    }

    public void setTserie(String tserie) {
        this.tserie = tserie;
    }

    public String getTubica() {
        return tubica;
    }

    public void setTubica(String tubica) {
        this.tubica = tubica;
    }

    public String getUnialt() {
        return unialt;
    }

    public void setUnialt(String unialt) {
        this.unialt = unialt;
    }

    public String getUnicon() {
        return unicon;
    }

    public void setUnicon(String unicon) {
        this.unicon = unicon;
    }

    public String getUnifac() {
        return unifac;
    }

    public void setUnifac(String unifac) {
        this.unifac = unifac;
    }

    public ST_UnidadMedida getUnidadMedida() {
        return unidadMedida;
    }

    public void setUnidadMedida(ST_UnidadMedida unidadMedida) {
        this.unidadMedida = unidadMedida;
    }
    
    public FC_Movimiento getMovimientoInicial() {
        return movimientoInicial;
    }

    public void setMovimientoInicial(FC_Movimiento movimientoInicial) {
        this.movimientoInicial = movimientoInicial;
    }

    public FC_Movimiento getMovimientoOriginal() {
        return movimientoOriginal;
    }

    public void setMovimientoOriginal(FC_Movimiento movimientoOriginal) {
        this.movimientoOriginal = movimientoOriginal;
    }

    public String getCodori() {
        return codori;
    }

    public void setCodori(String codori) {
        this.codori = codori;
    }

    public String getModori() {
        return modori;
    }

    public void setModori(String modori) {
        this.modori = modori;
    }

    public int getNroori() {
        return nroori;
    }

    public void setNroori(int nroori) {
        this.nroori = nroori;
    }
    
    public String getUnisec() {
        return unisec;
    }

    public void setUnisec(String unisec) {
        this.unisec = unisec;
    }

    public FC_Movimiento getMovimientoAplicacion() {
        return movimientoAplicacion;
    }

    public void setMovimientoAplicacion(FC_Movimiento movimientoAplicacion) {
        this.movimientoAplicacion = movimientoAplicacion;
    }

    public BigDecimal getPendiente() {
        return pendiente;
    }

    public void setPendiente(BigDecimal pendiente) {
        this.pendiente = pendiente;
    }

    public BigDecimal getTotalPendienteConIVA() {

        try {
            totalPendienteConIVA = BigDecimal.ZERO;                        
            if (pendiente != null) {

                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                BigDecimal impTotal = pendiente.multiply(impUnit);
                
                if (codcpt.equals("V001")) {
                    totalPendienteConIVA = impTotal.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    totalPendienteConIVA = impTotal.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    totalPendienteConIVA = impTotal;
                }
            }

            return totalPendienteConIVA;
        } catch (Exception e) {
             
             return BigDecimal.ZERO;
        }
    }

    public void setTotalPendienteConIVA(BigDecimal totalPendienteConIVA) {
        this.totalPendienteConIVA = totalPendienteConIVA;
    }

    public BigDecimal getTotalPendienteSinIVA() {

        try {
            totalPendienteSinIVA = BigDecimal.ZERO;

            if (pendiente != null) {
                totalPendienteSinIVA = pendiente.multiply(precio.add(precio.multiply(pctbfn.divide(new BigDecimal(100)))));
            }
            return totalPendienteSinIVA;
        } catch (Exception e) {            
            return BigDecimal.ZERO;
        }
    }

    public void setTotalPendienteSinIVA(BigDecimal totalPendienteSinIVA) {
        this.totalPendienteSinIVA = totalPendienteSinIVA;
    }

    public BigDecimal getTotalLineaConIVA() {

        try {
            if (cantid != null) {

                totalLineaConIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                BigDecimal impTotal = cantid.multiply(impUnit);

            
                if (codcpt.equals("V001")) {
                    totalLineaConIVA = impTotal.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    totalLineaConIVA = impTotal.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    totalLineaConIVA = impTotal;
                }
            }

            return totalLineaConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setTotalLineaConIVA(BigDecimal totalLineaConIVA) {
        this.totalLineaConIVA = totalLineaConIVA;
    }

    public BigDecimal getTotalLineaSinIVA() {

        try {
            totalLineaSinIVA = BigDecimal.ZERO;

            if (cantid != null) {
                totalLineaSinIVA = cantid.multiply(precio.add(precio.multiply(pctbfn.divide(new BigDecimal(100)))));
            }
            return totalLineaSinIVA;
        } catch (Exception e) {
            return BigDecimal.ZERO;
        }

    }

    public void setTotalLineaSinIVA(BigDecimal totalLineaSinIVA) {
        this.totalLineaSinIVA = totalLineaSinIVA;
    }

    public BigDecimal getPrecioListaConIVA() {
        try {
            if (precio != null) {

                precioListaConIVA = BigDecimal.ZERO;

                if (codcpt.equals("V001")) {
                    precioListaConIVA = precio.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    precioListaConIVA = precio.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    precioListaConIVA = precio;
                }
            }

            return precioListaConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }

    }

    public void setPrecioListaConIVA(BigDecimal precioListaConIVA) {
        this.precioListaConIVA = precioListaConIVA;
    }

    public BigDecimal getPrecioFinalConIVA() {
        try {
            if (precio != null) {

                precioFinalConIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);

                if (codcpt.equals("V001")) {
                    precioFinalConIVA = impUnit.multiply(new BigDecimal(1.21));
                }
                if (codcpt.equals("V002")) {
                    precioFinalConIVA = impUnit.multiply(new BigDecimal(1.105));
                }
                if (codcpt.equals("V003")) {
                    precioFinalConIVA = impUnit;
                }
            }

            return precioFinalConIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setPrecioFinalConIVA(BigDecimal precioFinalConIVA) {
        this.precioFinalConIVA = precioFinalConIVA;
    }
    
    public BigDecimal getPrecioFinalSinIVA() {

        try {
            if (precio != null) {
                
                precioFinalSinIVA = BigDecimal.ZERO;
                BigDecimal bonif = precio.multiply(pctbfn.divide(new BigDecimal(100)));
                BigDecimal impUnit = precio.add(bonif);
                precioFinalSinIVA = impUnit;
            }

            return precioFinalSinIVA;

        } catch (Exception e) {

            return BigDecimal.ZERO;
        }
    }

    public void setPrecioFinalSinIVA(BigDecimal precioFinalSinIVA) {
        this.precioFinalSinIVA = precioFinalSinIVA;
    }

    public ST_Producto getProductoOriginal() {
        return productoOriginal;
    }

    public void setProductoOriginal(ST_Producto productoOriginal) {
        this.productoOriginal = productoOriginal;
    }
    
    public GR_Auditoria getAuditoria() {
        return auditoria;
    }

    public void setAuditoria(GR_Auditoria auditoria) {
        this.auditoria = auditoria;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FC_ItemMovimiento other = (FC_ItemMovimiento) obj;
        if ((this.modfor == null) ? (other.modfor != null) : !this.modfor.equals(other.modfor)) {
            return false;
        }
        if ((this.codfor == null) ? (other.codfor != null) : !this.codfor.equals(other.codfor)) {
            return false;
        }
        if (this.nrofor != other.nrofor) {
            return false;
        }
        if (this.nroitm != other.nroitm) {
            return false;
        }
        if ((this.nivexp == null) ? (other.nivexp != null) : !this.nivexp.equals(other.nivexp)) {
            return false;
        }
        if ((this.modapl == null) ? (other.modapl != null) : !this.modapl.equals(other.modapl)) {
            return false;
        }
        if ((this.codapl == null) ? (other.codapl != null) : !this.codapl.equals(other.codapl)) {
            return false;
        }
        if (this.nroapl != other.nroapl) {
            return false;
        }
        if (this.itmapl != other.itmapl) {
            return false;
        }
        if ((this.expapl == null) ? (other.expapl != null) : !this.expapl.equals(other.expapl)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 17 * hash + (this.modfor != null ? this.modfor.hashCode() : 0);
        hash = 17 * hash + (this.codfor != null ? this.codfor.hashCode() : 0);
        hash = 17 * hash + this.nrofor;
        hash = 17 * hash + this.nroitm;
        hash = 17 * hash + (this.nivexp != null ? this.nivexp.hashCode() : 0);
        hash = 17 * hash + (this.modapl != null ? this.modapl.hashCode() : 0);
        hash = 17 * hash + (this.codapl != null ? this.codapl.hashCode() : 0);
        hash = 17 * hash + this.nroapl;
        hash = 17 * hash + this.itmapl;
        hash = 17 * hash + (this.expapl != null ? this.expapl.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "FC_ItemMovimiento{" + "modfor=" + modfor + "codfor=" + codfor + "nrofor=" + nrofor + "nroitm=" + nroitm + "nivexp=" + nivexp + "modapl=" + modapl + "codapl=" + codapl + "nroapl=" + nroapl + "itmapl=" + itmapl + "expapl=" + expapl + '}';
    }

    

}
